const TOKEN_KEY = "token";
const USER_INFO_KEY = 'user-info';
const PRIVACY_KEY = 'privacy';

// 获取本地存储
const getStorage = (key) => {
	try {
		const value = uni.getStorageSync(key);
		return value;
	} catch (e) {
		return false;
	}
}
// 设置本地存储
const setStorage = (key, value) => {
	try {
		uni.setStorageSync(key, value);
		return true;
	} catch (e) {
		return false;
	}
}
// 清除本地存储
const removeStorage = (key) => {
	try {
		uni.removeStorageSync(key);
		return true;
	} catch (e) {
		return false;
	}
}
// 清除所有存储
const clearStorage = () => {
	try {
		uni.clearStorageSync();
		return true;
	} catch (e) {
		return false;
	}
}

// token部分
const getToken = () => {
	return getStorage(TOKEN_KEY);
}
const setToken = (value) => {
	return setStorage(TOKEN_KEY, value);
}
const removeToken = () => {
	return removeStorage(TOKEN_KEY);
}

// userInfo部分
const getUserInfo = () => {
	return getStorage(USER_INFO_KEY);
}
const setUserInfo = (value) => {
	return setStorage(USER_INFO_KEY, value);
}
const removeUserInfo = () => {
	return removeStorage(USER_INFO_KEY);
}

// privacy部分
const getPrivacy = () => {
	return getStorage(PRIVACY_KEY);
}
const setPrivacy = (value) => {
	return setStorage(PRIVACY_KEY, value);
}
const removePrivacy = () => {
	return removeStorage(PRIVACY_KEY);
}

export {
	getStorage,
	setStorage,
	removeStorage,
	clearStorage,
	getToken,
	setToken,
	removeToken,
	getUserInfo,
	setUserInfo,
	removeUserInfo,
	getPrivacy,
	setPrivacy,
	removePrivacy,
}